package com.gitee.srurl.core.api.impl.duplicate;

import com.gitee.srurl.core.annotation.ApiImpl;
import com.gitee.srurl.core.constant.ApiTypeConstant;
import com.gitee.srurl.core.constant.RedisConstant;
import com.gitee.srurl.core.util.MurmurHashUtil;
import com.gitee.srurl.core.util.redis.RedisBloomUtil;
import com.google.common.hash.Hashing;

import java.nio.charset.StandardCharsets;

/**
 * MurmurHash检测
 *
 * @author zxw
 * @date 2023/4/19 22:25
 */
@ApiImpl(ApiTypeConstant.DuplicateDetection.MURMUR_HASH)
public class MurmurHashDuplicateDetection extends CacheDuplicateDetectionTemplate {

    @Override
    protected boolean cacheContains(String url) {
        return RedisBloomUtil.contains(RedisConstant.Bloom.BLOOM_DUPLICATE_MURMUR,
                MurmurHashUtil.murmur128(url));
    }
}
